<!DOCTYPE html>
<!--
This is a starter template page. Use this page to start your new project from
scratch. This page gets rid of all links and provides the needed markup only.
-->
<html>

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>充值处理</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <link rel="stylesheet" href="../bower_components/bootstrap/dist/css/bootstrap.min.css">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="../bower_components/font-awesome/css/font-awesome.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="../bower_components/Ionicons/css/ionicons.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="../dist/css/AdminLTE.css">
  <!-- AdminLTE Skins. We have chosen the skin-blue for this starter
        page. However, you can choose any other skin. Make sure you
        apply the skin class to the body tag so the changes take effect. -->
  <link rel="stylesheet" href="../dist/css/skins/skin-blue.min.css">

  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->

  <!-- Google Font -->
  <link rel="stylesheet" href="https://fonts.useso.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
  <link rel="stylesheet" href="../dist/css/mycss.css">
  <script src="../dist/js/myjs.js"></script>
</head>
<!--
BODY TAG OPTIONS:
=================
Apply one or more of the following classes to get the
desired effect
|---------------------------------------------------------|
| SKINS         | skin-blue                               |
|               | skin-black                              |
|               | skin-purple                             |
|               | skin-yellow                             |
|               | skin-red                                |
|               | skin-green                              |
|---------------------------------------------------------|
|LAYOUT OPTIONS | fixed                                   |
|               | layout-boxed                            |
|               | layout-top-nav                          |
|               | sidebar-collapse                        |
|               | sidebar-mini                            |
|---------------------------------------------------------|
-->

<body class="hold-transition skin-blue sidebar-mini">
  <div class="wrapper">

    <!-- Main Header -->
    <header class="main-header">
    </header>
    <!-- Left side column. contains the logo and sidebar -->
    <aside class="main-sidebar">
      <!-- /.sidebar -->
    </aside>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
      <!-- Content Header (Page header) -->
      <section class="content-header">
        <h1>
          首页
          <small>>管理中心>兑换处理</small>
        </h1>
      </section>

      <!-- Main content -->
      <section class="content container-fluid">

        <!--------------------------
        | Your Page Content Here |
        -------------------------->
        <!--coded By Bobo 2017/7/13-->
        <div class="box">
          <div class="box-body">

            <div>
              <!-- Nav tabs -->

              <!-- Tab panes -->
              <div class="tab-content">
                <div role="tabpanel" class="tab-pane active">
                  <table class="table table-hover c">
                    <tr>
                      <div id="searchResult"></div>
                    </tr>
                  </table>
                </div>
              </div>


            </div>
          </div>
          <!-- /.box-body -->
        </div>
      </section>
      <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->

    <!-- Main Footer -->
    <footer class="main-footer">
    </footer>
    <!-- Control Sidebar -->
    <aside class="control-sidebar control-sidebar-dark">
      <!-- Create the tabs -->
      <ul class="nav nav-tabs nav-justified control-sidebar-tabs">
        <li class="active"><a href="#control-sidebar-home-tab" data-toggle="tab"><i class="fa fa-home"></i></a></li>
        <li><a href="#control-sidebar-settings-tab" data-toggle="tab"><i class="fa fa-gears"></i></a></li>
      </ul>
      <!-- Tab panes -->
      <div class="tab-content">
        <!-- Settings tab content -->
        <div class="tab-pane" id="control-sidebar-settings-tab">
          <form method="post">
            <h3 class="control-sidebar-heading">General Settings</h3>

            <div class="form-group">
              <label class="control-sidebar-subheading">
              Report panel usage
              <input type="checkbox" class="pull-right" checked>
            </label>

              <p>
                Some information about this general settings option
              </p>
            </div>
            <!-- /.form-group -->
          </form>
        </div>
        <!-- /.tab-pane -->
      </div>
    </aside>
    <!-- /.control-sidebar -->
    <!-- Add the sidebar's background. This div must be placed
  immediately after the control sidebar -->
    <div class="control-sidebar-bg"></div>
  </div>
  <!-- ./wrapper -->

  <!-- REQUIRED JS SCRIPTS -->

  <!-- jQuery 3 -->
  <script src="../bower_components/jquery/dist/jquery.min.js"></script>
  <!-- Bootstrap 3.3.7 -->
  <script src="../bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
  <!-- AdminLTE App -->
  <script src="../dist/js/adminlte.js"></script>
  <script src="../dist/js/myjs.js"></script>
  <!-- Optionally, you can add Slimscroll and FastClick plugins.
     Both of these plugins are recommended to enhance the
     user experience. -->
  <script>
    /*
   *加载header、sider和footer
  */
    $(".main-header").load("mainheader.html");
    $(".main-sidebar").load("mainsider.html");
    $(".main-footer").load("../mainfooter.html");
    $(document).ready(function(){
        $(".target").removeClass("highlight");
      $(".chongzhi").addClass("highlight");
   });
    /*
    *
    */
    $(document).ready(function () {
      $("#material1").hide();
      $("#upload").click(function () {
        $("#material1").show();
      });
      $("#dmaterial1").click(function () {
        $("#material1").hide();
      });
    });
  </script>
  <script>
    //  $(document).ready(function(){
    function getCookie(objName) {//获取指定名称的cookie的值   
      var arrStr = document.cookie.split("; ");
      for (var i = 0; i < arrStr.length; i++) {
        var temp = arrStr[i].split("=");
        if (temp[0] == objName)
          return unescape(temp[1]);
      }
    }
    var tname = getCookie("tname");
    if (tname == "") {
      window.location.href = "login.html";
    }
    $("#tname").html(tname);
    var postBody = {
      userId: tname
    };
    $.ajax({
      type: 'POST',
      url: '/check/chongzhi/query',
      data: postBody,
      dataType: 'json',
      success: function (data) {
        var i = 0;
        for (var o in data) {
          console.log("成功请求：" + JSON.stringify(data));
          if (data[o].changeAgree == "3") {
            i++;
            $('<div class="well well-lg">' +
              '<table class="table table-hover"><tbody><tr>' +
              '<td class="text-left"><strong>申请单号<strong></td><td class="text-left"><span id="_id' + o + '">' + data[o]._id +
              '<td class="text-left"><strong>申请时间<strong></td><td class="text-left"><span id="date' + o + '">' + data[o].changedate +
              '</span></td><tr></tbody>' +
              '</span></td><td class="text-left"><strong>申请人<strong></td><td class="text-left"><span id="userId' + o + '">' + data[o].userId +
              '</span></td><td class="text-left"><strong>充值金额<strong></td><td class="text-left"><span id="amount' + o + '">' + data[o].amount +
              '</span></td></tr></tbody></table>' +
              '<ul id="pager' + o + '" class="pager"><li><button class="btn btn-primary btn-sm" id="' + o +
              '" onclick="agree(this)">同意申请</button></li>&nbsp&nbsp&nbsp&nbsp<li><button class="btn btn-primary btn-sm" id="' + o +
              '" onclick="reject(this)">拒绝申请</button></li></ul></hr>').appendTo("#searchResult");
          }
        }
        if (i == 0) {
          $("#searchResult").html("暂无需要处理的申请。");
        }
      }
    });
    //});
    //   document.getElementById('name').innerHTML=name;


    function agree(obj) {
      var num = obj.id;
      var pager = '#pager' + num + '';
      var astr = "#amount" + num;
      $(pager).replaceWith('<span class="pull-right" style="color:#00bfff;">已同意</span><br><hr>');

      var _rid = "#_id" + num;
 //     console.log("啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊" + $(_rid).html());
      var postBody = {
        _id: $(_rid).html(),
        agree: "1"
      };
      console.log("申请单号：" + $(_rid).html());
      console.log(JSON.stringify(postBody));
      $.ajax({
        type: 'POST',
        url: '/check/change/verify',
        data: postBody,
        dataType: 'json',
        success: function (data) {
        }
      }).error(function (err) {
        console.log(err);
        alert("服务器忙！请稍后再尝试");
      });
      // $.ajax({
      //   type: 'POST',
      //   url: '/check/change/verify',
      //   data: postBody,
      //   dataType: 'json',
      //   success: function (data) {
      //     console.log("data1 success" + JSON.stringify(data));
      //   }
      // }).error(function (err) {
      // });
    }

    function reject(obj) {
      var num = obj.id;
      var pager = '#pager' + num + '';
      $(pager).replaceWith('<span class="pull-right" style="color:#00bfff;">已拒绝</span><br><hr>');
      var _rid = "#_id" + num;
      //       var hstr="#userId"+num;
      var postBody = {
        _id: $(_rid).html(),
        agree: "2"
      };
      console.log(JSON.stringify(postBody));
      $.ajax({
        type: 'POST',
        url: '/check/change/verify2',
        data: postBody,
        dataType: 'json',
        success: function (data) {
          alert("已拒绝请求");
        }
      }).error(function (err) {
        console.log(err);
        alert("服务器忙！请稍后再尝试");
      });
      $.ajax({
        type: 'POST',
        url: '/check/change/verify',
        data: postBody,
        dataType: 'json',
        success: function (data) {
          console.log("data1 success reject" + JSON.stringify(data));
        }
      }).error(function (err) {
      });
    }
  </script>
</body>

</html>